package com.ftg.learn.boot.service;


import com.ftg.learn.boot.mapper.DeptMapper;
import com.ftg.learn.boot.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptService {


    @Autowired
    DeptMapper deptMapper;  //代理模式

    public List<Dept> showAll(int page,int limit,String deptno,String dname){
        int begin = (page - 1) * limit;
        deptno = ("".equals(deptno) ? null : deptno);
        dname = ("".equals(dname) ? null : dname);
        return deptMapper.showall(begin,limit, deptno,dname);
    }

    public int getcount(String deptno,String dname){
        deptno = ("".equals(deptno) ? null : deptno);
        dname = ("".equals(dname) ? null : dname);
        return deptMapper.getCount( deptno,dname);
    }

    public int delete(int deptno) {
        return deptMapper.deleteDeptno(deptno);
    }

    public int update(Dept dept) {
        // TODO Auto-generated method stub
        return deptMapper.update(dept);
    }

    public int add(Dept dept) {
        // TODO Auto-generated method stub
        return deptMapper.add(dept);
    }

}

